/**
 * @FileName Context.java
 * @Package com.designMode.state
 * -------------------------------------
 * @function Please write description of function
 * @Date 2016-1-19 下午12:59:16
 * -------------------------------------
 * Copyright (c) 2016,顾博君 All Rights Reserved.
 */
package com.designMode.state;

/**
 * @author 顾博君
 * @ClassName Context
 * @Date 2016-1-19 下午12:59:16
 * @Function 具体环境角色
 */
public class Context {
    public final static State STATE1 = new ConcreteState1();
    public final static State STATE2 = new ConcreteState2();
    /**
     * 当前状态
     */
    private State currentState;

    /**
     * 获取当前状态
     *
     * @return
     */
    public State getCurrentState() {
        return currentState;
    }

    /**
     * 定义状态
     *
     * @param currentState
     */
    public void setCurrentState(State currentState) {
        this.currentState = currentState;
        this.currentState.setContext(this);
    }

    /**
     * 行为委托
     */
    public void handle1() {
        this.currentState.handle1();
    }

    public void handle2() {
        this.currentState.handle2();
    }
}
